/**
 * Alipay.com Inc.
 * Copyright (c) 2004-2015 All Rights Reserved.
 */
package com.nuanshui.heatedloan.extension.interceptor;

import java.text.SimpleDateFormat;
import java.util.Date;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.nuanshui.framework.utils.LogUtil;


public class PerfLog {
   
    private static Logger logger =  LoggerFactory.getLogger("perf");
    
    private static ThreadLocal<Long> requestStartTime = new ThreadLocal<Long>();
    private static  SimpleDateFormat sf =new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");

  
    public static void printStart(String invoker) {
    	
    	Date curTime = new Date();
    	String time = sf.format(curTime);
        LogUtil.info(logger, invoker + " - S - " + time);
        requestStartTime.set(curTime.getTime());
    } 
    public static void printEnd(String invoker) {
    	Date curTime = new Date();
    	String time = sf.format(curTime);
    	
        LogUtil.info(logger, invoker + " - E - " + time+"  COST  "+(curTime.getTime()-requestStartTime.get()));
    }
}
